﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CMS.Repository.Translator
{
    public class StudentTranslator
    {
        public static Student ToStudentEF(CMS.Model.Student studentModel)
        {
            Student studentEF = new Student();
            studentEF.StudentId = studentModel.StudentId;
            studentEF.StudentName = studentModel.StudentName;
            studentEF.StudentGender = studentModel.StudentGender;
            studentEF.ClassId = studentModel.Grade.ClassId;
            return studentEF;
        }

        public static void ToStudentEF(CMS.Model.Student studentModel, Student studentEF)
        {
            studentEF.StudentId = studentModel.StudentId;
            studentEF.StudentName = studentModel.StudentName;
            studentEF.StudentGender = studentModel.StudentGender;
            studentEF.ClassId = studentModel.Grade.ClassId;
        }

        public static List<CMS.Model.Student> ToStudentModelList(List<Student> inputList)
        {
            List<CMS.Model.Student> studentModelList = new List<CMS.Model.Student>();
            foreach (Student s in inputList)
            {
                CMS.Model.Grade grades = new CMS.Model.Grade();
                CMS.Model.Student studentModel = new CMS.Model.Student(grades);
                studentModel.StudentId = s.StudentId;
                studentModel.StudentName = s.StudentName;
                studentModel.StudentGender = s.StudentGender;
                studentModel.Grade.ClassName = s.Class.ClassName;
                studentModelList.Add(studentModel);
            }
            return studentModelList;
        }

        public static CMS.Model.Student ToStudentModel(Student stu)
        {
            CMS.Model.Grade grade = new CMS.Model.Grade();
            grade.ClassId = stu.ClassId;
            CMS.Model.Student result = new CMS.Model.Student(grade);
            result.StudentId = stu.StudentId;
            result.StudentGender = stu.StudentGender;
            result.StudentName = stu.StudentName;
            return result;
        }

    }
}
